<template>
	<view class="integral-value">
		<view class="fix_box">
			<view class="menu-item" :class="selectIndex == index ? 'native' : ''" v-for="(item,index) in menus"
				@click="selectMenu(index)">{{item}}
			</view>
		</view>
		<view class="bg-box">
			<view class="bg-content"
				:style="{backgroundImage:'url('+$util.img('upload/uniapp/xxjk/bonusCenter/point-bg-icon@2x.png')+')'}">
				<block v-if="selectIndex == 0">
					<view class="bg-title">X数字资产价格</view>
				</block>
				<block v-else-if="selectIndex == 1">
					<view class="bg-title">数量池</view>
				</block>
				<block v-else>
					<view class="bg-title">分红池</view>
				</block>
				<view class="bg-num">{{showStr}}</view>
			</view>
		</view>
		<view class="">
			<view class="chart-filter-cta">
				<chart-filter :value="statistics_type" @change="changeTab"></chart-filter>
			</view>
			<view class="charts">
				<uCharts v-if="serverData.opts" :scroll="serverData.enableScroll" :show="canvas"
					:canvasId="serverData.id" :chartType="serverData.chartType" :extraType="serverData.extraType"
					:cWidth="cWidth" :cHeight="cHeight" :opts="serverData.opts" ref="order_total" />
			</view>
		</view>
		<loading-cover ref="loadingCover"></loading-cover>
	</view>
</template>

<script>
	import uCharts from './components/u-charts/u-charts.vue';
	// import qiunDataCharts from './components/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue';
	import chartFilter from './components/chart-flter.vue';
	import ordersDataCharts from './public/js/ordersDataCharts.js';
	export default {
		components: {
			chartFilter,
			uCharts
			// qiunDataCharts,
		},
		mixins: [ordersDataCharts],
		data() {
			return {
				menus: ['X数字资产', '数量池', '分红池'],
				selectIndex: 0,
				showStr: '',
				chartData: {},
				opts: {
					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					enableScroll: true,
					legend: {},
					xAxis: {
						disableGrid: false,
						scrollShow: true,
						itemCount: 4,
						gridType: "dash",
						dashLength: 2
					},
					yAxis: {
						disabled: true,
						gridType: "dash",
						dashLength: 2
					},
					extra: {
						line: {
							type: "straight",
							width: 2,
							activeType: "hollow"
						}
					}
				},
				statistics_type: '1'
			};
		},
		onLoad(option) {
			this.refreshChart();
		},
		methods: {
			/* 菜单选择 */
			selectMenu(index) {
				if (this.selectIndex != index) {
					this.selectIndex = index;
					this.statistics_type = '1';
					this.refreshChart();
				}
			},
			changeTab({
				value
			}) {
				this.statistics_type = value;
				this.refreshChart()
			},
			refreshChart() {
				this.getChartData().then(res => {})
			}
		}
	}
</script>

<style lang="scss">
	.integral-value {
		.fix_box {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			height: 98rpx;
			background: #fff;
			z-index: 999;
			display: flex;
			padding: 0 40rpx;

			.menu-item {
				width: 33%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;

				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #999999;
				line-height: 50rpx;

				&.native {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 34rpx;
					color: #FC311A;
					line-height: 50rpx;
				}
			}
		}

		.bg-box {
			margin-top: 122rpx;
			display: flex;
			align-items: center;
			justify-content: center;

			.bg-content {
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				width: 702rpx;
				height: 204rpx;
				background-size: cover;

				.bg-title {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: rgba(255, 255, 255, 0.8);
					line-height: 28rpx;
				}

				.bg-num {
					margin-top: 12rpx;
					font-family: Helvetica, Helvetica;
					font-weight: bold;
					font-size: 48rpx;
					color: #FFFFFF;
					line-height: 56rpx;
				}
			}
		}
	}

	.chart-filter-cta {
		margin-top: 42rpx;
		margin-bottom: 30rpx;
	}

	.chart-cta {
		padding: 42rpx 0;
		width: 709rpx;
		height: 500rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
	}
</style>